/**
 * @author Luc Yriarte
 * 
 * Licence : BSD http://www.opensource.org/licenses/bsd-license.php
 *  
 */
package basicSim;

public class Complex {
	// complex number z = a + i.b
	public double a,b,mod;
	
	static public double module(double a, double b) {
		return Math.sqrt(a*a+b*b);
	}

	public Complex() {
		a=b=mod=0;
	}

	public Complex(double real, double imaginary) {
		a=real;
		b=imaginary;
		mod = Complex.module(a,b);
//System.out.println(" z=a+ib : " + mod + " = " + a + " + i * " + b);
	}

	public Complex(Matrix m) {
		a=m.cell[0][0];
		b=m.cell[0][1];
		mod = Complex.module(a,b);
//System.out.println(" z=a+ib : " + mod + " = " + a + " + i * " + b);
	}

	public Matrix matrix() {
		Matrix mResult = new Matrix(2,2);
		mResult.cell[0][0] = a;
		mResult.cell[0][1] = b;
		mResult.cell[1][0] =-b;
		mResult.cell[1][1] = a;
		return mResult;
	}

	public Complex add(Complex z) {
		return new Complex(a+z.a, b+z.b);
	}
	
	public Complex mul(Complex z) {
		return new Complex(a*z.a-b*z.b, a*z.b+b*z.a);
	}
/*
	public Complex add(Complex z) {
		return new Complex(this.matrix().add(z.matrix()));
	}
	
	public Complex mul(Complex z) {
		return new Complex(this.matrix().mul(z.matrix()));
	}
*/	
}
